from mechine import Heat_recovery_system, steam_turbine, Condenser

Ne_DT = 346.625519
Pt_DT = 15.479736
Dsup_DT = 393.6354572222222
Sup_wat_T = 536.259888
Pb_DT = 5.431763
Re_attw_D = 0
Pre_real = 2.584305
Re_wat_T = 517.691833
h = 0.2
n_opt_initial = 40.050761083333335
Cond_wat_T = 51.08432
Cond_wat_D = 307.31041805555554
Feed_wat_D = 411.499905

state_result = [Ne_DT, 3.571, 2.261, 2.1, 2, 480, 500, 520, 900, 1.203,
                        0.6006, 0.3668, 0.1441, 0.04862, 62, 70, 77.85, 253, 5, 350,
                        83, 95, 107, 5, 474, 113, 120, 138, 5, 712,
                        167, 180, 188, 5, 823, 200, 210, 218, 5, 963,
                        220, 236, 245, 54, 180, 0.01, 0.51, Pb_DT / 1000]

Ne, Ps1, Ps2, P1, P2, T1, T2, Tj, Ty2, Ps3, \
        Ps4, Ps5, Ps6, Ps7, Tn7, Tl7, Tw7, hd7, Dd6, hd6, Tn6, \
        Tl6, Tw6, Dd5, hd5, Tn5, Tl5, Tw5, Dd3, hd3, Tn3, Tl3, Tw3, \
        Dd2, hd2, Tn2, Tl2, Tw2, Dd1, hd1, Tn1, Tl1, Tw1, Twc_m, Tw4, \
        drhol4_dt, rhol4_m, Pb = (state_result[item] for item in range(len(state_result)))

turbine = steam_turbine(0.8238)
heatsystem = Heat_recovery_system()
coldsystem = Condenser()

while True:

    Ds, pt, ht, D1, p1, D1j, h1, D2, p2, Dj2, h2, P2, T2, D2r, D3, p3, h3, Dj3, D4, p4, h4, \
                Dj4, D5, p5, h5, Dj5, D6, p6, h6, Dj6, D7, p7, h7, Dj7, hc, Dc, P1, T1, Tj, Ty2, Ne, Cond_T, Ne8 = turbine.simulation(
                Sup_wat_T, Pt_DT, Dsup_DT, Ps1, Ps2, Re_attw_D,
                Ne_DT, P1, P2, Pre_real, T1, T2, Re_wat_T, Tj, Ty2,
                Ps3, Ps4, Ps5, Ps6, Ps7, Pb_DT, h)
    # 凝汽器仿真
    _, Pb, Dec, Tc, Hc1, Vf, NTU, Qc = coldsystem.simulation(hc, Dc, Pb, n_opt_initial, Ta, h, 1.7175)

    # 回热系统仿真
    Ps7, Dd7, hd7, Tn7, Tl7, Tw7, Ps6, Dd6, hd6, Tn6, Tl6, Tw6, Ps5, Dd5, hd5, Tn5, Tl5, Tw5, \
        Ps4, Tw4, Ps3, Dd3, hd3, Tn3, Tl3, Tw3, Ps2, Dd2, hd2, Tn2, Tl2, Tw2, Ps1, Dd1, hd1, Tn1, Tl1, Tw1, \
        rhol4, Twc_m, Tw4_m, rhol4_m, drhol4_dt = heatsystem.simulation(
        Cond_wat_T, Tn7, Tl7, Ps7, Tw7, D7, h7, hd7, Dd6, hd6, Tn6, Tl6, Ps6, Tw6, D6, h6, Dd5, hd5, Tn5, Tl5, Ps5,
        Tw5, D5, h5, Ps4, Dd3, hd3, D4, h4, Dsup_DT, Tn3, Tl3, Ps3, Tw3, D3, h3, Dd2, hd2, Tn2, Tl2, Ps2, Tw2,
        D2, h2, Dd1, hd1, Tn1, Tl1, Ps1, Tw1, D1, h1, Cond_wat_D, Feed_wat_D, Tw4, Twc_m, drhol4_dt, rhol4_m, h)